package cn.hrbnu.web;

import cn.hrbnu.po.Comment;
import cn.hrbnu.service.CommentService;
import cn.hrbnu.util.ResponseResult;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhangyadong
 * @version 1.0
 * &#064;ClassName  CommentController
 * &#064;date  2025-06-12 8:50
 */

@RestController
@RequestMapping("/comment")
public class CommentController {

    private final CommentService commentService;

    public CommentController(CommentService commentService) {
        this.commentService = commentService;
    }

    /**
     * 获取评论列表
     *
     * @param articleId 文章ID，用于指定评论所属的文章
     * @param pageNum 页码，用于分页查询
     * @param pageSize 每页大小，用于分页查询
     * @return 返回包含评论列表的ResponseResult对象
     */
    @GetMapping("/commentList")
    public ResponseResult<Object> commentList(Long articleId,Integer pageNum,Integer pageSize){
        return commentService.commentList(articleId,  pageNum, pageSize);
    }

    @PostMapping
    public ResponseResult<Object> addComment(@RequestBody Comment comment){
        return commentService.addComment(comment);
    }

}